﻿//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NetCMS.Content;

public partial class user_friendmanage_add : NetCMS.Web.UI.UserPage
{
    Friend fri = new Friend();
    protected void Page_Load(object sender, EventArgs e)
    {
        
        Response.CacheControl = "no-cache";
    }   
   
    protected void shortCutsubmit(object sender, EventArgs e)
    {
        if (Page.IsValid)//判断是否通过验证
        {
            string UserNum = NetCMS.Global.Current.UserNum;
            string FriendName = Request.Form["FriendNameBox"].ToString();
            string Contents = NetCMS.Common.Input.Htmls(Request.Form["ContentBox"]);

            string Hail_Fellow = NetCMS.Common.Rand.Number(12);

            int cut = fri.sel_friendClass(UserNum,0);

            string selHail_Fellow = fri.sel_friendClass();

            NetCMS.Model.STFriendClass Fic;
            Fic.Content = Contents;
            Fic.FriendName = FriendName;
            Fic.HailFellow = Hail_Fellow;


            if (selHail_Fellow != Hail_Fellow)
            {
                if (cut > 5)
                {
                    PageError("添加错误,您所建立的好友分类超过五个不能在添加", "friendmanage.aspx");
                }
                else
                {
                    if (fri.add_friendClass(Fic, UserNum) == 0)
                    {
                        PageError("添加错误", "friendmanage.aspx");
                    }
                    else
                    {
                        PageRight("添加成功", "friendmanage.aspx");
                    }
                }
            }
            else 
            {
                PageError("添加错误可能编号重复", "friendmanage.aspx");
            }
        }
    }
}


